<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../css/index.css"/>
    <script src="../js/jquery-3.4.1.js"></script>
    <script src="../js/vue.min.js"></script>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>远方的树</title>
</head>
<body>

<div class="text" id="main">
    <img class="imga" src="../img/one.jpg">
    <div class="title_text">
        远方的树
    </div>

    <div class="input_text">
        <input class="input" style="margin-left: 5px" placeholder="输入对方名字查看留言" v-model="message" id="inputwenzi">
        <button class="but"  style="margin-right: 5px" @click="find">查看留言</button>
    </div>


<!--    语句循环展示结构 -->
    <div class="divls">
        <div class="ly1" v-for="i in ls">{{i}}</div>
    </div>
    <div href="index.html" class="at">
        <a href="singup">
            我要留言给他(她)
        </a>
    </div>

</div>
<script>
    new Vue({
        el:"#main",
        data:function (){
            return{
                message:"",
                ls:[]
            }
        },
        methods:{
            find(){
                const that = this;
                const text = $("#inputwenzi").val();
                if(text === ''){
                    alert("您还未输入任何内容!");
                    return false;
                }else {
                    $.ajax({
                        url:"index",
                        type:"post",
                        dataType:"json",
                        data:{name:text},
                        success : function(data) {
                            that.ls = data["List"];
                        }
                    })
                    // this.ls = ["暂无内容"]
                }
            }
        }
    })

    // function find(){
    //     const text = $("#inputwenzi").val();
    //     if(text === ''){
    //         alert("您还未输入任何内容!");
    //         return false;
    //     }else {
    //
    //     }
    // }
</script>


</body>
</html>